NOTICE: This article originally appeared in the October, '88 issue of MichiganAtari Magazine and may be freely distributed or reprinted in non-profit UserGroup publications as long as the article's author and Michigan Atari Magazineare credited AND this notice is reprinted with the article. All otherpublications must obtain written permission from Unicorn Publications, 3487Braeburn Circle, Ann Arbor, MI 48108, Phone: (313) 973-8825 before using thisarticle.The Sport of Sortsby Clinton Pierce (GAG)In this installment we're going to look at one of the most fundamentalproblems in computers, sorting. Human beings, as a rule, have an amazingsense of geometric perception. They will sort index cards with names on themby placing the names in relative order on the table (A is a lot farther awayfrom P, than M is), and doing fine adjustments as they go along.Computers aren't human. They must sort using absolutes. You must tell themwhat is to be sorted (records), how it is to be sorted (keys), and where it isto go to (output). And they can only compare (again, as a rule) two things ata time.The first sort is the standard Hey-I-learned-that-in-BASIC sort: the bubblesort. The bubble sort compares two elements in an array, and if they are inthe wrong order, swiches them around. It is finished when either n^2repetitions have occured, or when no more switches are made in an entirepass.The next sort is Shell's sort (named after a man, not the method). APseudo-BASIC program follows for an array a, N elements long: 1.M=N 2.M=Intger part of M/2, If m=0 then the sort is done else: J=1, K=N-M 3. I=J 4.L=I+M, If a(i) a(x) down one element, make z(q)=a(x),Increase X and Q. #3 Go to step 2 until q=N. This sort is moderately fast.Next, Quicksort, is the fastest sort I've dealt with. A complete algorythmwill not be given until the unit on Recursion. But here's how it works: Givenan array 1..N, arrange the array so that all values < a pivot value, arefirst, and > pivot are last. Then, the pivot is in its proper place. It isthen done again, and again, using each smaller region until the array issorted. The sort is incredibly fast. The number of passes needed is only Ntimes the Base-2 log of N. (Where bubblesort would use 4096 repetitions,quicksort uses 384).Until next time....Hasta Luego.